﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using SSTU.Extensions;
using SSTU.Model;
using SSTU.ViewModel.Core;

namespace SSTU.ViewModel.Item
{
	/// <summary>
	/// View model for periodic week.
	/// </summary>
	public class PeriodicWeekItemVM :ViewModelBase
	{
		private PeriodicWeekType _type;

		/// <summary>
		/// Initializes a new instance of the <see cref="PeriodicWeekItemVM"/> class.
		/// </summary>
		/// <param name="type">The type.</param>
		public PeriodicWeekItemVM(PeriodicWeekType type)
			: this(type, null)
		{
		}

		/// <summary>
		/// Create instance with concrete values.
		/// </summary>
		public PeriodicWeekItemVM(PeriodicWeekType type, IEnumerable<PeriodicWeekDayItemVM> days)
		{
			Type = type;
			Days = new ObservableCollection<PeriodicWeekDayItemVM>();
			if (days != null)
			{
				Days.AddRange(days);
			}
		}

		/// <summary>
		/// Gets or sets week type.
		/// </summary>
		public PeriodicWeekType Type
		{
			get { return _type; }
			set
			{
				if (value != _type)
				{
					RaisePropertyChanging<PeriodicWeekType>(() => Type);
					_type = value;
					RaisePropertyChanged<PeriodicWeekType>(() => Type);
				}
			}
		}

		/// <summary>
		/// Gets observable collection of days at this week.
		/// </summary>
		public ObservableCollection<PeriodicWeekDayItemVM> Days
		{
			get;
			private set;
		}
	}
}
